<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<title>我的</title>
		<!--标准mui.css-->
		<link rel="stylesheet" href="../css/mui.min.css">
		<script src="../js/mui.min.js"></script>
		<script src="../js/jquery.min.js"></script>
		<style>
			html,
			body {
				height: 100%;
			}

			.mui-slider-handle>span {
				color: darkgray;
				position: absolute;
				right: 0;
			}
		</style>
	</head>
	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">我的发布</h1>
		</header>

		<div class="mui-content">
			<ul id="OA_task_1" class="mui-table-view">
				<!-- -----------------数据填充------------------------------------ -->
				<!-- <li class="mui-table-view-cell">
					<div class="mui-slider-right mui-disabled">
						<a class="mui-btn mui-btn-red" onclick="del(123)">删除</a>
					</div>
					<div class="mui-slider-handle">
						空调坏了<span>19-8-18</span>
					</div>
				</li>
				<li class="mui-table-view-cell">
					<div class="mui-slider-right mui-disabled">
						<a class="mui-btn mui-btn-red">删除</a>
					</div>
					<div class="mui-slider-handle">
						教室门锁坏了<span>19-8-18</span>
					</div>
				</li> -->
				<!-- -----------------数据填充------------------------------------ -->
			</ul>

		</div>


	</body>
	<script>
		mui.init();
		var id;
		mui.plusReady(function() {
			id = plus.storage.getItem('uID');
			init();
		});

		function init() {
			var obj = {
				"uID": id
			};
			mui.ajax({
				url: 'http://120.27.247.180:8080/School/safeProblem/getUserAll',
				type: "post",
				async: true,
				data: obj,
				dataType: "json",
				contentType: "application/x-www-form-urlencoded; charset=utf-8",
				jsonp: "jsoncallback",
				success: function(data) {
					//发布信息
					var Ele = jQuery("#OA_task_1");
					Ele.empty();
					var info = data.list;
					for (var i = 0, l = info.length; i < l; i++) {
						var date = new Date(info[i].issueTime);
						var time = date.getFullYear() + "/" + (date.getMonth() + 1) + "/" + date.getDate();
						var tempEle = '<li class="mui-table-view-cell">' +
							'<div class="mui-slider-right mui-disabled">' +
							'<a class="mui-btn mui-btn-red" onclick="del(' + info[i]['safeID'] + ')">删除</a>' +
							'</div>' +
							'<div class="mui-slider-handle">' + info[i].description + '<span>' + time + '</span>' +
							'</div></li>';
						Ele.append(tempEle);
					}

				},
				error: function() {
					mui.toast("网络异常");
				}
			});
		}

		//删除发布信息
		function del(fabuhao) {
			var btnArray = ['确认', '取消'];
			mui.confirm('确认删除此次发布？', '提示', btnArray, function(e) {
				if (e.index == 0) {
					var obj = {
						safeID: fabuhao
					};
					mui.ajax({
						url: 'http://120.27.247.180:8080/School/safeProblem/delete',
						type: "post",
						async: false,
						data: obj,
						dataType: "json",
						contentType: "application/x-www-form-urlencoded; charset=utf-8",
						jsonp: "jsoncallback",
						success: function(data) {
							if (data.suc) {
								mui.toast("删除成功");
								init();
							} else
								mui.toast("删除失败");
						},
						error: function() {
							mui.toast("服务器异常，请稍后再试");
						}
					});
				} else {
					setTimeout(function() {
						$.swipeoutClose(li);
					}, 0);
				}
			});
		}
	</script>
</html>
